package com.eight.cloud.mybatisplus.method;

import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import com.eight.cloud.mybatisplus.annotation.enums.MpSqlMethod;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.SqlSource;

/**
 * 根据id查询 忽略逻辑删除
 *
 * @ClassName: SelectRealById
 * @Author: TXC
 * @Date: 2024-12-18 17:16
 **/
public class SelectRealById extends AbstractMethod {
    public SelectRealById() {
        this(MpSqlMethod.SELECT_REAL_BY_ID.getMethod());
    }

    public SelectRealById(String name) {
        super(name);
    }

    @Override
    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
        MpSqlMethod sqlMethod = MpSqlMethod.SELECT_REAL_BY_ID;
        SqlSource sqlSource = super.createSqlSource(this.configuration, String.format(sqlMethod.getSql(),
                this.sqlSelectColumns(tableInfo, false), tableInfo.getTableName(), tableInfo.getKeyColumn(),
                tableInfo.getKeyProperty(), ""), Object.class);
        return this.addSelectMappedStatementForTable(mapperClass, this.methodName, sqlSource, tableInfo);
    }
}
